<?php 
	//iterar por lista de doctypes y armar el string
	$doctypes = Helper_Service::factory("identitycard")->getList();
	$count = count($doctypes);
						  		 
   	$i=0;
   	$doctypes_string = "";
   	foreach($doctypes as $id=>$description){
   		$doctypes_string.= $id.":".$description[0]."";
   		if (($i+1) < $count) $doctypes_string.= ";";
   		else $doctypes_string.= "";
   		$i++;
   }
						  	
?>
<script type="text/javascript">
	//List Configuration
	$j("#list_patient").jqGrid({
		url:'patient/list',
		datatype:'json',
		mtype:'POST',
		colNames:['Apellido', 'Nombre','Tipo de documento', 'N° Documento'],
		colModel:[
		          {name:'surname', index:'surname', width:30, searchoptions:{ sopt:['eq','bw','ew','cn']}},
		          {name:'name', index:'name', width:30, searchoptions:{ sopt:['eq','bw','ew','cn']}},
		          {name:'doctype', index:'doctype', width:20, stype:'select', searchoptions:{ value: "<?php echo $doctypes_string;?>",sopt:['eq']}},
		          {name:'identity_card_number', index:'identity_card_number', width:20,align:"right", searchoptions:{ sopt:['eq','lt','le','gt', 'ge']}}
		],
		pager:'#gridpager_patient',
		loadtext: 'Cargando Lista de Pacientes ...',
		rowNum:10,
		rowList:[10],
		sortname:'surname',
		sortorder:'asc',
		autowidth:true,
		viewrecords:true,
		onSelectRow:function(id){
			//a cambiarse
			$("div.main-content").load("/diastole/patient/get",{'id':id});
		},
		editurl:'',
		scrollOffset:0
		//caption:'Actividades'
	});

	$j("#list_patient").setGridHeight(220);
	
	//Form editing
	$j("#list_patient").jqGrid('navGrid','#gridpager_patient',{
			add:false,
			edit:false,
			del:false,
			search:true
	});
</script>